package com.medicine.service.impl;

import org.springframework.stereotype.Service;

import com.medicine.dao.impl.TeacherDao;

import pagination.Page;
import po.Gys;
import po.SuperAdmin;
import po.SuperAdmin;
import requestvo.GysReqVo;
import requestvo.SuperAdminReqVo;
import requestvo.SuperAdminReqVo;

@Service
public class SuperAdminService extends BaseServiceImpl {

	public String hasSuperAdmin(String userId, String password) {
		// TODO 自动生成的方法存根
		if (userId != null && password != null) {
			try {
				SuperAdminReqVo superAdminReqVo = superAdminDao.get(userId);
				if (superAdminReqVo.getSgly_psw().equals(password)) {
					String username = superAdminReqVo.getSgly_name();
					return username;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public String ifHasSuperAdmin(String userId) {
		// TODO 自动生成的方法存根
		if (userId != null) {
			try {
				SuperAdminReqVo superAdmin = superAdminDao.get(userId);
				String username = superAdmin.getSgly_name();
				return username;
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}
		return null;
	}
	
	public String ifHasSuperAdminName(String userId) {
		// TODO 自动生成的方法存根
		if (userId != null) {
			try {
				SuperAdminReqVo superAdmin = superAdminDao.get(userId);
				String username = superAdmin.getSgly_name();
				return username;
			} catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}
		return null;
	}

	public Page findSuperAdminInfo(SuperAdminReqVo superAdminReqVo) {
		Page<SuperAdminReqVo> page = new Page<>();
		if (superAdminReqVo.getTech_no() != null
				&& !superAdminReqVo.getTech_no().equals("")) {
			page.getParams().put("tech_no", superAdminReqVo.getTech_no());
		}
		if (superAdminReqVo.getTech_name() != null
				&& !superAdminReqVo.getTech_no().equals("")) {
			page.getParams().put("tech_name",
					"%" + superAdminReqVo.getTech_name() + "%");
		}
		if (superAdminReqVo.getTech_psw() != null
				&& !superAdminReqVo.getTech_psw().equals("")) {
			page.getParams().put("tech_psw", superAdminReqVo.getTech_psw());
		}
		if (superAdminReqVo.getTech_tel() != null
				&& !superAdminReqVo.getTech_tel().equals("")) {
			page.getParams().put("tech_tel",
					"%" + superAdminReqVo.getTech_tel() + "%");
		}
		/*
		 * if(superAdminReqVo.getTech_name()!=null&&
		 * !superAdminReqVo.getTech_no().equals("")){
		 * page.getParams().put("gysfzr", "%"+superAdminReqVo.getTech_name()+"%");
		 * }
		 */
		page.setPageNo(superAdminReqVo.getPage());
		page.setPageSize(superAdminReqVo.getRows());
		page.setResults(superAdminDao.findPage(page));
		return page;
	}

	public void updateSuperAdminInfo(SuperAdminReqVo superAdminReqVo) {
		// TODO Auto-generated method stub
		superAdminDao.update(superAdminReqVo);

	}

	public void addSuperAdminInfo(SuperAdminReqVo superAdminReqVo) {
		// TODO Auto-generated method stub
		superAdminDao.insert(superAdminReqVo);
	}

	public void delSuperAdminInfo(String[] integers) {
		// TODO Auto-generated method stub
		superAdminDao.delete(integers);
	}

}
